<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>打印库存</title>
    <script src="/jquery-1.8.3.min.js"></script>
    <script src="/printThis.js"></script>
    <script src="/chineseMoney.js"></script>
    <script src="/tools.js"></script>
    <link rel="stylesheet" href="/print.css"/>
</head>
<body>
<div id="receiptPrintArea0">
    <h3 style="text-align: center">库存明细清单<span class="originalProcess"></span></h3>
    <br/>
    <table style="width: 100%;" class="printTable">
        <thead style="border: 1px solid">
        <td width="10%">类别</td>
        <td width="25%">名称</td>
        <td width="20%">规格</td>
        <td width="20%">品牌</td>
        <td width="10%">单位</td>
        <td width="15%">数量</td>
        </thead>
        <tbody id="content">
        </tbody>
    </table>
</div>
<script th:inline="javascript">
    var params = [[${params}]];
    var backAddress = params.backAddress;
    var typeId = params.typeId ;
    var originalProcess = params.originalProcess;
    function print() {
        $("#receiptPrintArea0").printThis({
            debug: false,
            importCSS: true,
            importStyle: true,
            printContainer: true,
            pageTitle: "",
            removeInline: false,
            printDelay: 333,
            header: null,
            formValues: true
        });
    }
    $.ajax({
            url: backAddress + "/api/stock/printStockData",
            type: "post",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            data : JSON.stringify({
                "backAddress" : backAddress,
                "typeId" : typeId,
                "originalProcess" : originalProcess
             }),
            success: function (data) {
                //console.log(data)
                $(".originalProcess")[0].innerText = getOriginalProcess(originalProcess);
                var str = '' ;
                for (var i = 0 ; i < data.data.length ; i++) {
                    str = "<tr><td width=\"10%\">" + data.data[i].typeName + "</td>" +
                            "<td width=\"25%\">" + data.data[i].name + "</td>" +
                            "<td width=\"20%\">" + dealNull(data.data[i].specs) + "</td>" +
                            "<td width=\"20%\">" + dealNull(data.data[i].brand) + "</td>" +
                            "<td width=\"10%\">" + dealNull(data.data[i].unitName) + "</td>" +
                            "<td width=\"15%\">" + data.data[i].amount + "</td></tr>" ;
                    $("#content").append($(str));
                }
                print()
            },
            error: function (status) {
                alert(status)
            }
        }
    )
</script>
</body>
</html>